package com.srv.persistence;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import com.srv.common.TravelField;
import com.srv.model.Travel;
import com.srv.util.ObjectField;

import junit.framework.TestCase;

public class TravelPersistenceTestCase extends TestCase {
	
	public void testTravelPersistence() throws PersistenceException{
		ITravelPersistence persistence = PersistenceFactory.getTravelPersistence();
		
		String tid = UUID.randomUUID().toString();
		Travel travel = new Travel();
		travel.pid = 24;
		travel.travelID = tid;
		travel = persistence.insertTravel(travel);
		assertEquals(tid, travel.travelID);
		
		travel = persistence.getTravel(travel.pid, travel.travelID);
		assertNotNull(travel);
		
		Map<ObjectField, Object> map = new HashMap<ObjectField, Object>();
		map.put(TravelField.TITLE, "测试标题");
		boolean b = persistence.updateTravel(travel.pid, travel.travelID, map);
		assertTrue(b);
	}
}
